package com.jiazhong.basic.shuxin.net;

import lombok.SneakyThrows;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

// 接收方
public class DemoF2 {

    @SneakyThrows
    public static void main(String[] args) {
        DatagramSocket socket = new DatagramSocket(9999);
        byte[] buf = new byte[1024];
        DatagramPacket packet = new DatagramPacket(buf, buf.length);
        socket.receive(packet);
        String str = new String(packet.getData(), 0, packet.getLength());
        System.out.println(str);
    }
}
